BITS 32

section .text
global inb
global outb
global inw
global outw
global inl
global outl

; uint8 inb(uint16 port)
inb:
    push ebp
    mov ebp, esp
    mov dx, [ebp + 8]
    in al, dx
    movzx eax, al
    pop ebp
    ret

; void outb(uint16 port, uint8 value)
outb:
    push ebp
    mov ebp, esp
    mov dx, [ebp + 8]
    mov al, [ebp + 12]
    out dx, al
    pop ebp
    ret

; uint16 inw(uint16 port)
inw:
    push ebp
    mov ebp, esp
    mov dx, [ebp + 8]
    in ax, dx
    movzx eax, ax
    pop ebp
    ret

; void outw(uint16 port, uint16 value)
outw:
    push ebp
    mov ebp, esp
    mov dx, [ebp + 8]
    mov ax, [ebp + 12]
    out dx, ax
    pop ebp
    ret

; uint32 inl(uint16 port)
inl:
    push ebp
    mov ebp, esp
    mov dx, [ebp + 8]
    in eax, dx
    pop ebp
    ret

; void outl(uint16 port, uint32 value)
outl:
    push ebp
    mov ebp, esp
    mov dx, [ebp + 8]
    mov eax, [ebp + 12]
    out dx, eax
    pop ebp
    ret